<?php
/**
 *  
 * 
 * @package Cms
 * @license 2008 
 */

/**
 * Collabor 
 *
 * @package Cms
 * 
 */

abstract class Cms_Ajax
{
	public function __construct()
	{
		$this->init();
	}
	
	/**
	 * Overrides by extended Class
	 *
	 */
	public function init()
	{
		
	}
	
	/**
	 * Check if any Post parameters have been sent
	 *
	 * return boolan if and only if Post parameters have been sent
	 */
	public function checkPost()
	{
		if(!isset($_POST)) {
			return false;
		}
		
		return true;
	}
	
	/**
	 * Not Empty Validation
	 *
	 * @param string $element
	 * @return boolean if and only if Element is not empty
	 */
	public function notEmpty($element = null)
	{
		if($element == null || $element == '' || empty($element)) {
			return false;
		}
		
		return true;
	}
	
	public function sendJson($jsonData = null)
	{
		echo json_encode($jsonData);
	}
	
	public function isValidEmail($value)
    {
        return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $value);	
    }
}